package com.ly.crawl.impl;

import com.ly.crawl.Capturer;
import org.jsoup.nodes.Document;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class DBUrlCapturer implements Capturer<Set<String>> {
    private int count;
    private String table, urlCol = "url", alisa = urlCol;

    public DBUrlCapturer(String table, String urlCol) {
        this.table = table;
        this.urlCol = urlCol;
        this.alisa = urlCol.replaceAll("(.+\\s+)?(\\w+)","$2");
    }

    public DBUrlCapturer(String table) {
        this.table = table;
    }

    @Override
    public Set<String> capture(String url, Document doc) {
        return null;
    }

//    @Override
//    public Set<String> capture(String url, Document doc) {
//        if (count == 0) {
//            count++;
//            return DBHelper.selectListMap("select distinct " + urlCol + " from " + table).stream()
//                    .map(m -> m.get(alisa)).collect(
//                            () -> new HashSet<String>(),
//                            (set, u) -> set.add(u + ""),
//                            (s1, s2) -> s1.addAll(s2)
//                    );
//        }
//        return Collections.emptySet();
//    }
}
